﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EnvDTE;
using System.Windows.Forms;
using Crude.VisualStudioAddin.BuildEngine;

namespace Crude.VisualStudioAddin.Actions
{
    class UpdateOverrideAllLocalAction : BaseSolutionAction
    {
        public override string Name
        {
            get { return "UpdateOverrideAllLocal"; }
        }

        public override string Caption
        {
            get { return "Update Override All Projects Dependencies"; }
        }

        public override string Tooltip
        {
            get { return "Update all the project dependencies and override the local changes"; }
        }

        public override void ExecuteAction(EnvDTE80.DTE2 applicationObject)
        {
            IList<string> projects = new List<string>();

            foreach (Project project in applicationObject.Solution.Projects)
            {
                if (!string.IsNullOrEmpty(project.FullName))
                {
                    Core.Project crudeProject = new Core.Project(project.FullName);

                    if (crudeProject.IsImportLineExisted())
                    {
                        projects.Add(project.FullName);
                    }
                }
            }



            Engine.Instance.Build(projects, "UpdateLocalOverride", "Update and override local repository");
            
        }
    }
}
